package util

import "github.com/gin-gonic/gin"

/**
 *@Author: yepeng
 *@Date: 2022/4/5 17:55
 *@Name: http
 *@Desc:
 */

// RetResp 返回通用json返回体
func RetResp(ctx *gin.Context, httpCode, retCode int, data interface{}, msg string) {
	ctx.JSON(httpCode, gin.H{
		"code": retCode,
		"data": data,
		"msg":  msg,
	})
}

// RetSucResp 返回成功数据json
func RetSucResp(ctx *gin.Context, data interface{}) {
	RetResp(ctx, 200, 200, data, "success")
}

// RetErrResp 返回错误数据json
func RetErrResp(ctx *gin.Context, errCode int, errMsg string, data interface{}) {
	RetResp(ctx, 200, errCode, data, errMsg)
	return
}
